package com.gitee.mazhenggg.mall.point.mybatis.impl;


import com.gitee.mazhenggg.mall.point.domain.repository.PointRepository;
import com.gitee.mazhenggg.mall.point.domain.type.UserId;
import com.gitee.mazhenggg.mall.point.domain.type.Value;
import com.gitee.mazhenggg.mall.point.mybatis.builder.PointDOBuilder;
import com.gitee.mazhenggg.mall.point.mybatis.mapper.PointDOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;


@Repository
public class PointRepositoryImpl implements PointRepository {
    @Autowired
    PointDOMapper pointDOMapper;


    @Override
    public Value getPointByUserId(UserId userId) {
        Long point = pointDOMapper.findPointByUserId(userId.getValue());
        return new Value(point);
    }

    @Override
    public void updatePointByUserId(UserId userId, Value point) {
        pointDOMapper.updatePointByUserId(userId.getValue(), point.getValue());
    }
}